<?php

class AppController extends Controller {
    var $components = array('Acl', 'Auth','Session','Email');

	function beforeFilter() {
        Security::setHash('md5');
		
       if ($this->Session->read('grupo') != null){
			$group = $this->Session->read('grupo');
			$this->set('menu',$group);
		}else{
			$this->set('menu','welcome');
		} 
		
		//Configure AuthComponent
		$this->Auth->authorize = 'actions';
		$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
        $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
        $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'welcome');
		$this->Auth->loginError = "No, you fool!  That's not the right password!";
		$this->Auth->authError = "Sorry, you are lacking access.";
		$this->Auth->actionPath = 'controllers/';
	
//		$this->Auth->allow('*');
//		$this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'welcome');
	 	
	}

    function beforeRender () {
       $this->_setErrorLayout();
	}

	function _setErrorLayout() {
    	if($this->name == 'CakeError') {
        	$this->layout = 'error';
    	}
	}

}



?>
